package process_demo.review.wait_notify;

/**
 * @author haomin
 * @date 2022/09/12 11:49
 **/
public class Demo2 {
    static class MyThread extends Thread{
        private Object o;
        public MyThread (Object o){
            this.o = o;
        }

        @Override
        public void run() {
            synchronized (o){
                System.out.println("执行唤醒命令");
                o.notify();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Object o1 = new Object();
        Object o2 = new Object();
        Object o3 = new Object();

        MyThread t = new MyThread(o1);
        t.start();

        synchronized (o1){
            synchronized (o2){
                synchronized (o3){
                    o3.wait(); // 只释放o3的锁
                }
            }
        }
    }
}